package com.youlu.campus.web.jinshuju;

import com.youlu.campus.entity.VO.req.UserDoQaVO;
import com.youlu.campus.entity.jinshuju.dto.QueryJinUserImportDTO;
import com.youlu.campus.service.jinshuju.JinShuJuActivityService;
import com.youlu.campus.service.jinshuju.JinShuJuQaService;
import com.youlu.campus.service.jinshuju.JinUserImportService;
import com.youlu.campus.web.common.base.RequestContext;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 金数据业务
 */
@RestController
public class JinShuJuQaController {


    @Autowired
    private JinShuJuQaService jinShuJuQaService;

    @Autowired
    private JinShuJuActivityService jinShuJuActivityService;

    @Autowired
    private JinUserImportService jinUserImportService;

    /**
     * 获取答题题库信息
     *
     * @param activityId
     * @return
     */
    @GetMapping("/public/jin/qa-info")
    public QResult qaInfo(String activityId) {
        return QResult.success(jinShuJuQaService.findQaInfoByActivityId(activityId));
    }


    /**
     * 提交答题信息
     *
     * @param
     * @return
     */
    @PostMapping("/public/jin/qa-commit")
    public QResult qaResultCommit(@RequestBody UserDoQaVO req) {
        return QResult.success(jinShuJuQaService.qaResultCommit(req));
    }

    /**
     * 提交答题信息
     *
     * @param
     * @return
     */
    @PostMapping("/mini-app/jin/qa-commit")
    public QResult qaCommit(@RequestBody UserDoQaVO req) {
        req.setUserPO(RequestContext.getCurUser());
        return QResult.success(jinShuJuQaService.qaResultCommit(req));
    }


    /**
     * 活动进度页
     *
     * @param activityId
     * @return
     */
    @GetMapping("/mini-app/jin/activity/progress")
    public QResult activityProgress(String activityId) {
        return QResult.success(jinShuJuQaService.findActivityProgressByActivityId(activityId, RequestContext.getCurUser()));
    }

    /**
     * 获取用户答题成绩
     *
     * @param activityId
     * @return
     */
    @GetMapping("/mini-app/jin/qa/transcript")
    public QResult userQaTranscript(String activityId) {
        return QResult.success(jinShuJuQaService.findUserQaTranscriptByActivityId(activityId, RequestContext.getCurUser()));
    }

    /**
     * 查询信息首页
     *
     * @param activityId
     * @return
     */
    @GetMapping("/public/jin/query/index")
    public QResult queryIndex(String activityId) {
        return QResult.success(jinShuJuActivityService.queryIndex(activityId));
    }


    /**
     * 用户报名提示
     *
     * @param
     * @return
     */
    @PostMapping("/public/jin/invite/feed-info")
    public QResult userInviteFeedInfo(@RequestBody QueryJinUserImportDTO dto) {
        return QResult.success(jinUserImportService.list(dto));
    }


    /**
     * 用户报名提示
     *
     * @param
     * @return
     */
    @PostMapping("/public/jin/feed-info")
    public QResult userFeedInfo(@RequestBody QueryJinUserImportDTO dto) {
        return QResult.success(jinUserImportService.feedList(dto));
    }


    /**
     * 查询报名用户前信息
     *
     * @param activityId
     * @return
     */
    @GetMapping("/public/jin/before/sign-up")
    public QResult beforeActivitySignUp(String activityId) {
        return QResult.success(jinShuJuActivityService.findSignUpActivityByActivityId(activityId));
    }

    /**
     * 查询活动其他信息
     *
     * @param activityId
     * @return
     */
    @GetMapping("/public/jin/other-info")
    public QResult otherInfo(String activityId) {
        return QResult.success(jinShuJuActivityService.getOtherInfo(activityId));
    }

}
